// +FHDR------------------------------------------------------------
//                 Copyright (c) 2023 NOVAUTO.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : async_hand_fifo.v
// Author        : ICer
// Created On    : 2023-12-28 18:32
// Last Modified : 2024-01-10 15:10 by ICer
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------


module async_hand_fifo #(
    //parameter
    parameter WIDTH = 8,
    parameter DEPTH = 10
)( /*AUTOARG*/
   // Outputs
   data_in_ready, data_out_valid, data_out,
   // Inputs
   w_clk, w_rst_n, r_clk, r_rst_n, data_in_valid, data_in,
   data_out_ready
   );

// ----------------------------------------------------------------
// Interface declare
// ----------------------------------------------------------------
input             w_clk;
input             w_rst_n;

input             r_clk;
input             r_rst_n;

input             data_in_valid;
output            data_in_ready;
input [WIDTH -1:0]data_in;

output            data_out_valid;
input             data_out_ready;
output[WIDTH -1:0]data_out;

// ----------------------------------------------------------------
// Wire declare
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// AUTO declare
// ----------------------------------------------------------------
/*AUTOWIRE*/

wire wfull;
wire rempty;

wire winc = (data_in_valid && data_in_ready);
wire rinc = (data_out_valid && data_out_ready);

assign data_in_ready  = !wfull;
assign data_out_valid = !rempty;

/*async_fifo AUTO_TEMPLATE(
.winc(winc),
.rdata(data_out[]),
.wdata(data_in[]),
);
*/
async_fifo #(/*AUTOINSTPARAM*/
             // Parameters
             .WIDTH                     (WIDTH),
             .DEPTH                     (DEPTH))
u_fifo(/*AUTOINST*/
       // Outputs
       .wfull                           (wfull),
       .rdata                           (data_out[WIDTH-1:0]),   // Templated
       .rempty                          (rempty),
       // Inputs
       .w_clk                           (w_clk),
       .w_rst_n                         (w_rst_n),
       .r_clk                           (r_clk),
       .r_rst_n                         (r_rst_n),
       .winc                            (winc),                  // Templated
       .wdata                           (data_in[WIDTH-1:0]),    // Templated
       .rinc                            (rinc));

endmodule
// Local Variables:
// verilog-auto-inst-param-value:t
// verilog-library-directories:(".")
// verilog-library-extensions:(".v")
// End:

